#include "dht11.h"
#include "board.h"
#define CONFIG_LOG_NCOLOR 1
#include "log.h"
#include "bflb_mtimer.h"

int main()
{
    board_init();

    printf("dht11 start\n");
    DHT11_t dht;
    struct bflb_device_s* gpio;
    gpio = bflb_device_get_by_name("gpio");
    dht_init(gpio, &dht, GPIO_PIN_10);
    int ret = 0;
    int16_t temp = 0;
    uint16_t humidity = 0;
    
    while (1) {

        ret = dht_read_data(gpio, &dht, &temp, &humidity);
        if (ret == DHT_CODE_SUCCEED) {
            LOG_I("温度：%.1fC°, 湿度：%.1f%%\n", temp / 10.0f, humidity / 10.0f);
        }
        else {
            LOG_E("ret: %d\n", ret);
        }

        bflb_mtimer_delay_ms(2000);

    }
    return 0;
}